home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 13 / FreelogHS13.iso / P To P / Emule24b_Morph_Mod_V4b-binary / Webserver / General.js < prev    next >
Text File  |  2002-12-18  |  4KB  |  169 lines

  1. function lib_bwcheck()
  2. { //Browsercheck (needed)
  3.     this.ver=navigator.appVersion
  4.     this.agent=navigator.userAgent
  5.     this.dom=document.getElementById?1:0
  6.     this.opera5=this.agent.indexOf("Opera 5")>-1
  7.     this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
  8.     this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  9.     this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  10.     this.ie=this.ie4||this.ie5||this.ie6
  11.     this.mac=this.agent.indexOf("Mac")>-1
  12.     this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  13.     this.ns4=(document.layers && !this.dom)?1:0;
  14.     this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
  15.     return this
  16. }
  17. var bw=new lib_bwcheck();
  18.  
  19. function setContent(newcontent, objectname)
  20. {
  21.     if(document.all)
  22.     {
  23.       var obj=eval(objectname);
  24.       if(obj)
  25.           obj.innerHTML=newcontent;
  26.         else
  27.           alert(objectname+" doesn't exists");
  28.     }
  29.     else if(document.getElementById)
  30.     {
  31.         rng = document.createRange();
  32.         el = document.getElementById(objectname);
  33.         rng.setStartBefore(el);
  34.         htmlFrag = rng.createContextualFragment(newcontent);
  35.         while(el.hasChildNodes())
  36.             el.removeChild(el.lastChild);
  37.         el.appendChild(htmlFrag);
  38.     }
  39. }
  40.  
  41. function lib_obj(obj,nest,dnest,ddnest,num)
  42. {
  43.   if(!bw.ns4)
  44.     this.evnt=bw.dom && document.getElementById(obj)||bw.ie4 && document.all[obj];
  45.   else
  46.   {
  47.     if(ddnest)
  48.     {
  49.       this.evnt=document[nest].document[dnest].document[ddnest].document[obj]?document[nest].document[dnest].document[ddnest].document[obj]:0;
  50.     }
  51.     else if(dnest)
  52.     {
  53.       this.evnt=document[nest].document[dnest].document[obj]?document[nest].document[dnest].document[obj]:0;
  54.     }
  55.     else if(nest)
  56.     {
  57.       this.evnt=document[nest].document[obj]?document[nest].document[obj]:0;
  58.     }
  59.     else
  60.     {
  61.       this.evnt=document.layers[obj]?document.layers[obj]:0;
  62.     }
  63.   }
  64.   if(!this.evnt)
  65.     return lib_message('The layer does not exist ('+obj+') - Exiting script\n\nIf your using Netscape please check the nesting of your tags!');
  66.     this.elm = bw.ns4?eval(nest+"document.layers." +obj):bw.ie4?document.all[obj]:document.getElementById(obj);
  67.      this.css = bw.ns4?this.elm:this.elm.style;
  68.     this.scrollWidth = bw.ns4?this.css.document.width:this.elm.offsetWidth;
  69.     this.x = bw.ns4?this.css.left:this.elm.offsetLeft;
  70.     this.y = bw.ns4?this.css.top:this.elm.offsetTop;
  71.   if(!bw.bw)
  72.     return lib_message('Old browser');
  73.   this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;
  74.   this.ref=bw.dom||bw.ie4?document:this.css.document;
  75.   this.w=this.evnt.offsetWidth||this.css.clip.width||this.ref.width||this.css.pixelWidth||0;
  76.   this.h=this.evnt.offsetHeight||this.css.clip.height||this.ref.height||this.css.pixelHeight||0;
  77.   this.moveIt=lib_moveIt;
  78.   this.moveBy=lib_moveBy;
  79.   this.resize=lib_resize;
  80.   this.showIt=lib_showIt;
  81.   this.hideIt=lib_hideIt;
  82.   this.num=num;
  83.   this.clipTo=lib_clipTo;
  84.   this.obj = obj + "Object";
  85.   eval(this.obj + "=this");
  86.   return this
  87. }
  88.  
  89. function lib_clipTo(t,r,b,l,setwidth)
  90. {
  91.   if(t<0) t=0;
  92.   if(r<0) r=0;
  93.   if(b<0) b=0;
  94.   if(l<0) l=0;
  95.   this.ct=t;
  96.   this.cr=r;
  97.   this.cb=b;
  98.   this.cl=l
  99.   if(bw.ns4)
  100.   {
  101.     this.css.clip.top=t;
  102.     this.css.clip.right=r;
  103.     this.css.clip.bottom=b;
  104.     this.css.clip.left=l;
  105.   }
  106.   else if(bw.opera5)
  107.   {
  108.     this.css.pixelWidth=r;
  109.     this.css.pixelHeight=b;
  110.     this.w=r;
  111.     this.h=b;
  112.   }
  113.   else
  114.   {
  115.     this.css.clip="rect("+t+","+r+","+b+","+l+")";
  116.     if(setwidth)
  117.     {
  118.       this.css.width=r;
  119.       this.css.height=b;
  120.       this.w=r;
  121.       this.h=b;
  122.     }
  123.   }
  124. }
  125.  
  126. function lib_doc_size()
  127. { //Page positions - needed!
  128.   this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;
  129.   if(bw.ns6) this.x2-=2;
  130.   this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
  131.   if(bw.ns6) this.y2-=4;
  132.   if(!this.x2||!this.y2) return message('Document has no width or height');
  133.   this.x50=this.x2/2; this.y50=this.y2/2;
  134.   this.x10=(this.x2*10)/100;
  135.   this.y10=(this.y2*10)/100;
  136.   this.ytop=140*100/this.y2;
  137.   this.avail=(this.y2*(100-this.ytop))/100;
  138.   this.origy=this.y2;
  139.   return this;
  140. }
  141. function lib_moveIt(x,y)
  142. {
  143.   this.x=x;
  144.   this.y=y;
  145.   this.css.left=x;
  146.   this.css.top=y;
  147. }
  148. function lib_moveBy(x,y)
  149. {
  150.   this.moveIt(this.x+x,this.y+y);
  151. }
  152. function lib_resize(w,h)
  153. {
  154.   if(h<0) h=0;
  155.   if(w<0) w=0;
  156.   this.w=w;
  157.   this.h=h;
  158.   this.css.width=w;
  159.   this.css.height=h;
  160. }
  161. function lib_showIt()
  162. {
  163.   this.css.visibility="visible";
  164. }
  165. function lib_hideIt()
  166. {
  167.   this.css.visibility="hidden";
  168. }
  169.